package com.aigc.sclassroom.service.impl;

import com.aigc.sclassroom.mapper.FeedbackMapper;
import com.aigc.sclassroom.pojo.Feedback;
import com.aigc.sclassroom.service.FeedbackService;
import com.aigc.sclassroom.utils.ThreadLocalUtil;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Autowired
    private FeedbackMapper feedbackMapper;
    @Override
    public List<Feedback> list(Long surveyId) {
        return feedbackMapper.selectAll(surveyId);
    }

    @Override
    public void add(Feedback feedback) {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        Long userId =(id.longValue());
        feedback.setUserId(userId);
        feedbackMapper.add(feedback);
    }

}
